<template>
  <BaseContainer>
    <aplid-base-crud ref="crud" class="w-100" v-bind="baseConfig" :beforeOnLoadFormate="beforeOnLoadFormate">
      <template v-slot:approvalTime="{row}">
        {{ row.approvalTime || row.approvalTimes.split(',')[0]}}
      </template>
      <template v-slot:grantDate="{row}">
        {{ row.grantDate || row.grantDates.split(',')[0]}}
      </template>
      <template v-slot:detailDialog="{row,show}">
        <RuleForm v-if="show" :isDetail="row.grantStatus==1" :nowRowData="row" @refresh="handleRefresh"></RuleForm>
      </template>
    </aplid-base-crud>
  </BaseContainer>
</template>

<script setup lang="ts">
import { ref,nextTick } from 'vue'
import {baseConfig} from './config'
import RuleForm from './RuleForm/index.vue'
import { getAreaObj } from '@/utils/util'

const props = withDefaults(defineProps<{
  subsidyType?:string
}>(), {
	subsidyType:'9'
})

const crud:any = ref(null)
const handleRefresh = (query) => {
  nextTick(() => {
    crud.value.refreshChange(query)
  })
}

const beforeOnLoadFormate = (query:any)=> {
  return new Promise((resolve, reject) => {
			const crAreasObj: any = getAreaObj(query.authAreas, '')
			resolve({
				...query,
				...crAreasObj,
				authAreas: undefined,
        subsidyType: props.subsidyType
			})
		})
}

</script>
<style scoped lang="scss">
</style>